

// source idl: com.erp.organization.dao.idl.OrganizationDao.java

#ifndef ORGANIZATIONDAO_STUB_4_WEB_H
#define ORGANIZATIONDAO_STUB_4_WEB_H

#include <string>
#include <sstream>
#include "app_platform/cmd_obj.h"
#include "app_platform/cgi_stub_cntl.h"
#include "c2cent/base/basestub4web.h"
#include "app_platform/cntl_info.h"
#include "app_platform/intf_serializable.h"
#include "app_platform/intf_service_object.h"
#include <set>	
#include <map>	
#include <vector>	
#include "erp/organization/ddo/branchddo_organization.h"	
#include "erp/organization/ddo/organizationfilterddo_organization.h"	
#include "intf_organizationdao.h"

namespace erp
{
namespace organization
{
namespace dao
{
	#define ORGANIZATIONDAO_STUB4WEB_VERSION "ERP_ORGANIZATION_DAO___ORGANIZATIONDAO__STUB4WEB_VERSION__1.0 2013-10-23 11:04:01"
    const std::string ORGANIZATIONDAO_STUB4WEB_NOUSE = ORGANIZATIONDAO_STUB4WEB_VERSION;

	const uint32_t ORGANIZATIONDAO_DELETEBRANCH_REQ_CMD_ID = 0xC04E1802; /// 请求命令号
	const uint32_t ORGANIZATIONDAO_DELETEBRANCH_RESP_CMD_ID = 0xC04E8802; /// 回应命令号
	

	const uint32_t ORGANIZATIONDAO_FINDBRANCH_REQ_CMD_ID = 0xC04E1804; /// 请求命令号
	const uint32_t ORGANIZATIONDAO_FINDBRANCH_RESP_CMD_ID = 0xC04E8804; /// 回应命令号
	

	const uint32_t ORGANIZATIONDAO_GETBRANCH_REQ_CMD_ID = 0xC04E1803; /// 请求命令号
	const uint32_t ORGANIZATIONDAO_GETBRANCH_RESP_CMD_ID = 0xC04E8803; /// 回应命令号
	

	const uint32_t ORGANIZATIONDAO_MODIFYBRANCH_REQ_CMD_ID = 0xC04E1801; /// 请求命令号
	const uint32_t ORGANIZATIONDAO_MODIFYBRANCH_RESP_CMD_ID = 0xC04E8801; /// 回应命令号
	


	const uint16_t ORGANIZATIONDAO_MAX_PROTOCAL_VERSION = 2; //>平台支持的最大协议版本号

///////////////////////////// STRUCTS /////////////////////////////////////////////////
	/**
	 *
 	 * 
	 *
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CDeleteBranchReq : public IServiceObject, public ISerializableXML
	{
		std::string machineKey;
		std::string source;
		uint32_t sceneId;
		uint32_t option;
		std::set<uint64_t > branchId;
		std::string inReserve;
		std::string errmsg;
		std::map<uint64_t,uint32_t > errorCode;
		std::map<uint64_t,std::string > errorMsg;
		std::string outReserve;
		
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_DELETEBRANCH_REQ_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
			//检查协议的版本号
		    //if(bs.getVersion() > ORGANIZATIONDAO_MAX_PROTOCAL_VERSION)
		    //return false;
			bs & machineKey;
			bs & source;
			bs & sceneId;
			bs & option;
			bs & branchId;
			bs & inReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	
	/**
	 *
 	 * 
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CDeleteBranchResp : public IServiceObject, public ISerializableXML
	{
		uint32_t dwResult;
		std::string errmsg;
		std::map<uint64_t,uint32_t > errorCode;
		std::map<uint64_t,std::string > errorMsg;
		std::string outReserve;
	
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_DELETEBRANCH_RESP_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
		    bs & dwResult;
			bs & errmsg;
			bs & errorCode;
			bs & errorMsg;
			bs & outReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	/**
	 *
 	 * 
	 *
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CFindBranchReq : public IServiceObject, public ISerializableXML
	{
		std::string machineKey;
		std::string source;
		uint32_t sceneId;
		uint32_t option;
		erp::organization::ddo::COrganizationFilterDdo filter;
		std::string inReserve;
		std::string errmsg;
		uint32_t total;
		std::vector<erp::organization::ddo::CBranchDdo > branch;
		std::string outReserve;
		
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_FINDBRANCH_REQ_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
			//检查协议的版本号
		    //if(bs.getVersion() > ORGANIZATIONDAO_MAX_PROTOCAL_VERSION)
		    //return false;
			bs & machineKey;
			bs & source;
			bs & sceneId;
			bs & option;
			filter.Serialize(bs);
			bs & inReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	
	/**
	 *
 	 * 
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CFindBranchResp : public IServiceObject, public ISerializableXML
	{
		uint32_t dwResult;
		std::string errmsg;
		uint32_t total;
		std::vector<erp::organization::ddo::CBranchDdo > branch;
		std::string outReserve;
	
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_FINDBRANCH_RESP_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
		    bs & dwResult;
			bs & errmsg;
			bs & total;
			bs & branch;
			bs & outReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	/**
	 *
 	 * 
	 *
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CGetBranchReq : public IServiceObject, public ISerializableXML
	{
		std::string machineKey;
		std::string source;
		uint32_t sceneId;
		uint32_t option;
		std::set<uint64_t > branchId;
		std::string inReserve;
		std::string errmsg;
		std::map<uint64_t,uint32_t > errorCode;
		std::map<uint64_t,std::string > errorMsg;
		std::map<uint64_t,erp::organization::ddo::CBranchDdo > branch;
		std::string outReserve;
		
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_GETBRANCH_REQ_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
			//检查协议的版本号
		    //if(bs.getVersion() > ORGANIZATIONDAO_MAX_PROTOCAL_VERSION)
		    //return false;
			bs & machineKey;
			bs & source;
			bs & sceneId;
			bs & option;
			bs & branchId;
			bs & inReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	
	/**
	 *
 	 * 
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CGetBranchResp : public IServiceObject, public ISerializableXML
	{
		uint32_t dwResult;
		std::string errmsg;
		std::map<uint64_t,uint32_t > errorCode;
		std::map<uint64_t,std::string > errorMsg;
		std::map<uint64_t,erp::organization::ddo::CBranchDdo > branch;
		std::string outReserve;
	
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_GETBRANCH_RESP_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
		    bs & dwResult;
			bs & errmsg;
			bs & errorCode;
			bs & errorMsg;
			bs & branch;
			bs & outReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	/**
	 *
 	 * 
	 *
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CModifyBranchReq : public IServiceObject, public ISerializableXML
	{
		std::string machineKey;
		std::string source;
		uint32_t sceneId;
		uint32_t option;
		erp::organization::ddo::CBranchDdo branch;
		std::string inReserve;
		std::string errmsg;
		std::string outReserve;
		
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_MODIFYBRANCH_REQ_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
			//检查协议的版本号
		    //if(bs.getVersion() > ORGANIZATIONDAO_MAX_PROTOCAL_VERSION)
		    //return false;
			bs & machineKey;
			bs & source;
			bs & sceneId;
			bs & option;
			branch.Serialize(bs);
			bs & inReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	
	/**
	 *
 	 * 
	 *
 	 * @date 2013-10-23 11:04:01
 	 * @version 0
	 */	
	struct CModifyBranchResp : public IServiceObject, public ISerializableXML
	{
		uint32_t dwResult;
		std::string errmsg;
		std::string outReserve;
	
	    virtual uint32_t getCmdId() const { return ORGANIZATIONDAO_MODIFYBRANCH_RESP_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
		    bs & dwResult;
			bs & errmsg;
			bs & outReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	class COrganizationDaoStub4Web : public c2cent::CBaseStub4Web, public IOrganizationDao	{
		public:
			uint32_t DeleteBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const std::set<uint64_t >& branchId,
				const std::string& inReserve,
				std::string& errmsg,
				std::map<uint64_t,uint32_t >& errorCode,
				std::map<uint64_t,std::string >& errorMsg,
				std::string& outReserve
			);
			uint32_t FindBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const erp::organization::ddo::COrganizationFilterDdo& filter,
				const std::string& inReserve,
				std::string& errmsg,
				uint32_t& total,
				std::vector<erp::organization::ddo::CBranchDdo >& branch,
				std::string& outReserve
			);
			uint32_t GetBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const std::set<uint64_t >& branchId,
				const std::string& inReserve,
				std::string& errmsg,
				std::map<uint64_t,uint32_t >& errorCode,
				std::map<uint64_t,std::string >& errorMsg,
				std::map<uint64_t,erp::organization::ddo::CBranchDdo >& branch,
				std::string& outReserve
			);
			uint32_t ModifyBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const erp::organization::ddo::CBranchDdo& branch,
				const std::string& inReserve,
				std::string& errmsg,
				std::string& outReserve
			);
	};
	
	/**
	 *
 	 * 删除分支机构（逻辑）
	 *
		 *@param String machineKey: 机器码，必填  				
		 *@param String source: 调用来源，必填  				
		 *@param uint32_t sceneId: 场景ID，必填  				
		 *@param uint32_t option: 功能选项，扩展选填  				
		 *@param Set branchId: 需删除的分支机构的ID，必填  				
		 *@param String inReserve: 请求保留字  				
		 *@param String errmsg: 错误信息  		
		 *@param Map errorCode: 删除失败的错误码 		
		 *@param Map errorMsg: 删除失败的错误信息 		
		 *@param String outReserve: 返回保留字   		
     *
     *@return uint32_t : 0(成功) 其它失败
	 */	
	inline uint32_t COrganizationDaoStub4Web::DeleteBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const std::set<uint64_t >& branchId,
				const std::string& inReserve,
				std::string& errmsg,
				std::map<uint64_t,uint32_t >& errorCode,
				std::map<uint64_t,std::string >& errorMsg,
				std::string& outReserve
	)
	{
		 CDeleteBranchReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.option = option;
			oReq.branchId = branchId;
			oReq.inReserve = inReserve;
			oReq.errmsg = errmsg;
			oReq.errorCode = errorCode;
			oReq.errorMsg = errorMsg;
			oReq.outReserve = outReserve;
		 
		// CCGI_STUB_CNTL->setRouteKey(uint32_t routeKey); 没有设置routeKey  
		
	    CCGI_STUB_CNTL->setPassport(
	        rCntlInfo.getOperatorUin(), 
	        rCntlInfo.getOperatorKey().c_str(),
	        rCntlInfo.getOperatorClientIP());
	
		if(const_cast<CCntlInfo&>(rCntlInfo).isRouteKeySet())	
			CCGI_STUB_CNTL->setUin(const_cast<CCntlInfo&>(rCntlInfo).getRouteKey());	
	    
	    int iRetCode = 0;
		m_sErrMsg.clear();
		if((iRetCode = CCGI_STUB_CNTL->putSvcObj(&oReq, 0)) != 0)
	    {
			m_sErrMsg = "DoRequest failed: ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
	        return iRetCode;
	    }
	    
	    // Send & Recv
		if((iRetCode = SendRecv()) != 0)
		{
			if(99 == iRetCode) // UDP & Need No Response
				return 0;
	
			std::stringstream oss;
			oss << m_lTimeout;
	        m_sErrMsg = "Send & Recv Timeout(";
			m_sErrMsg += oss.str();
			m_sErrMsg += "s) ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
			return iRetCode;
	    }
	    
		if(!m_poCmd->isValid(ORGANIZATIONDAO_DELETEBRANCH_RESP_CMD_ID))
	    {
	        std::stringstream oss;
            oss << "Cmd not match: "
                << "Expected cmd=" << std::hex << ORGANIZATIONDAO_DELETEBRANCH_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << m_poCmd->getCmdId() << std::dec;
            m_sErrMsg = oss.str();
        
	        return 0xEE0024;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    m_poCmd->getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CDeleteBranchResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0028;
	    }
		    
			errmsg  = oResp.errmsg;
			errorCode  = oResp.errorCode;
			errorMsg  = oResp.errorMsg;
			outReserve  = oResp.outReserve;
		    
		return oResp.dwResult;
	}
	/**
	 *
 	 * 根据过滤条件查询支机构列表信息
	 *
		 *@param String machineKey: 机器码，必填  				
		 *@param String source: 调用来源，必填  				
		 *@param uint32_t sceneId: 场景ID，必填  				
		 *@param uint32_t option: 功能选项，扩展选填  				
		 *@param OrganizationFilterDdo filter: 过滤器，必填  				
		 *@param String inReserve: 请求保留字  				
		 *@param String errmsg: 错误信息  		
		 *@param uint32_t total: 分支机构总数 		
		 *@param Vector branch: 分支机构列表信息 		
		 *@param String outReserve: 返回保留字   		
     *
     *@return uint32_t : 0(成功) 其它失败
	 */	
	inline uint32_t COrganizationDaoStub4Web::FindBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const erp::organization::ddo::COrganizationFilterDdo& filter,
				const std::string& inReserve,
				std::string& errmsg,
				uint32_t& total,
				std::vector<erp::organization::ddo::CBranchDdo >& branch,
				std::string& outReserve
	)
	{
		 CFindBranchReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.option = option;
			oReq.filter = filter;
			oReq.inReserve = inReserve;
			oReq.errmsg = errmsg;
			oReq.total = total;
			oReq.branch = branch;
			oReq.outReserve = outReserve;
		 
		// CCGI_STUB_CNTL->setRouteKey(uint32_t routeKey); 没有设置routeKey  
		
	    CCGI_STUB_CNTL->setPassport(
	        rCntlInfo.getOperatorUin(), 
	        rCntlInfo.getOperatorKey().c_str(),
	        rCntlInfo.getOperatorClientIP());
	
		if(const_cast<CCntlInfo&>(rCntlInfo).isRouteKeySet())	
			CCGI_STUB_CNTL->setUin(const_cast<CCntlInfo&>(rCntlInfo).getRouteKey());	
	    
	    int iRetCode = 0;
		m_sErrMsg.clear();
		if((iRetCode = CCGI_STUB_CNTL->putSvcObj(&oReq, 0)) != 0)
	    {
			m_sErrMsg = "DoRequest failed: ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
	        return iRetCode;
	    }
	    
	    // Send & Recv
		if((iRetCode = SendRecv()) != 0)
		{
			if(99 == iRetCode) // UDP & Need No Response
				return 0;
	
			std::stringstream oss;
			oss << m_lTimeout;
	        m_sErrMsg = "Send & Recv Timeout(";
			m_sErrMsg += oss.str();
			m_sErrMsg += "s) ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
			return iRetCode;
	    }
	    
		if(!m_poCmd->isValid(ORGANIZATIONDAO_FINDBRANCH_RESP_CMD_ID))
	    {
	        std::stringstream oss;
            oss << "Cmd not match: "
                << "Expected cmd=" << std::hex << ORGANIZATIONDAO_FINDBRANCH_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << m_poCmd->getCmdId() << std::dec;
            m_sErrMsg = oss.str();
        
	        return 0xEE0024;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    m_poCmd->getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CFindBranchResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0028;
	    }
		    
			errmsg  = oResp.errmsg;
			total  = oResp.total;
			branch  = oResp.branch;
			outReserve  = oResp.outReserve;
		    
		return oResp.dwResult;
	}
	/**
	 *
 	 * 根据分支机构ID批量获取分支机构信息
	 *
		 *@param String machineKey: 机器码，必填  				
		 *@param String source: 调用来源，必填  				
		 *@param uint32_t sceneId: 场景ID，必填  				
		 *@param uint32_t option: 功能选项，扩展选填  				
		 *@param Set branchId: 需获取的分支机构的ID，必填  				
		 *@param String inReserve: 请求保留字  				
		 *@param String errmsg: 错误信息  		
		 *@param Map errorCode: 获取失败的错误码 		
		 *@param Map errorMsg: 获取失败的错误信息 		
		 *@param Map branch: 获取成功的分支机构信息 		
		 *@param String outReserve: 返回保留字   		
     *
     *@return uint32_t : 0(成功) 其它失败
	 */	
	inline uint32_t COrganizationDaoStub4Web::GetBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const std::set<uint64_t >& branchId,
				const std::string& inReserve,
				std::string& errmsg,
				std::map<uint64_t,uint32_t >& errorCode,
				std::map<uint64_t,std::string >& errorMsg,
				std::map<uint64_t,erp::organization::ddo::CBranchDdo >& branch,
				std::string& outReserve
	)
	{
		 CGetBranchReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.option = option;
			oReq.branchId = branchId;
			oReq.inReserve = inReserve;
			oReq.errmsg = errmsg;
			oReq.errorCode = errorCode;
			oReq.errorMsg = errorMsg;
			oReq.branch = branch;
			oReq.outReserve = outReserve;
		 
		// CCGI_STUB_CNTL->setRouteKey(uint32_t routeKey); 没有设置routeKey  
		
	    CCGI_STUB_CNTL->setPassport(
	        rCntlInfo.getOperatorUin(), 
	        rCntlInfo.getOperatorKey().c_str(),
	        rCntlInfo.getOperatorClientIP());
	
		if(const_cast<CCntlInfo&>(rCntlInfo).isRouteKeySet())	
			CCGI_STUB_CNTL->setUin(const_cast<CCntlInfo&>(rCntlInfo).getRouteKey());	
	    
	    int iRetCode = 0;
		m_sErrMsg.clear();
		if((iRetCode = CCGI_STUB_CNTL->putSvcObj(&oReq, 0)) != 0)
	    {
			m_sErrMsg = "DoRequest failed: ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
	        return iRetCode;
	    }
	    
	    // Send & Recv
		if((iRetCode = SendRecv()) != 0)
		{
			if(99 == iRetCode) // UDP & Need No Response
				return 0;
	
			std::stringstream oss;
			oss << m_lTimeout;
	        m_sErrMsg = "Send & Recv Timeout(";
			m_sErrMsg += oss.str();
			m_sErrMsg += "s) ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
			return iRetCode;
	    }
	    
		if(!m_poCmd->isValid(ORGANIZATIONDAO_GETBRANCH_RESP_CMD_ID))
	    {
	        std::stringstream oss;
            oss << "Cmd not match: "
                << "Expected cmd=" << std::hex << ORGANIZATIONDAO_GETBRANCH_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << m_poCmd->getCmdId() << std::dec;
            m_sErrMsg = oss.str();
        
	        return 0xEE0024;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    m_poCmd->getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CGetBranchResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0028;
	    }
		    
			errmsg  = oResp.errmsg;
			errorCode  = oResp.errorCode;
			errorMsg  = oResp.errorMsg;
			branch  = oResp.branch;
			outReserve  = oResp.outReserve;
		    
		return oResp.dwResult;
	}
	/**
	 *
 	 * 添加/修改分支机构；传入分支机构ID不为0时则进行修改，反之则进行添加；不能进行逻辑删除
	 *
		 *@param String machineKey: 机器码，必填  				
		 *@param String source: 调用来源，必填  				
		 *@param uint32_t sceneId: 场景ID，必填  				
		 *@param uint32_t option: 功能选项，扩展选填  				
		 *@param BranchDdo branch: 分支机构PO，必填  				
		 *@param String inReserve: 请求保留字  				
		 *@param String errmsg: 错误信息  		
		 *@param String outReserve: 返回保留字   		
     *
     *@return uint32_t : 0(成功) 其它失败
	 */	
	inline uint32_t COrganizationDaoStub4Web::ModifyBranch(
				const CCntlInfo& rCntlInfo,

				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				uint32_t option,
				const erp::organization::ddo::CBranchDdo& branch,
				const std::string& inReserve,
				std::string& errmsg,
				std::string& outReserve
	)
	{
		 CModifyBranchReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.option = option;
			oReq.branch = branch;
			oReq.inReserve = inReserve;
			oReq.errmsg = errmsg;
			oReq.outReserve = outReserve;
		 
		// CCGI_STUB_CNTL->setRouteKey(uint32_t routeKey); 没有设置routeKey  
		
	    CCGI_STUB_CNTL->setPassport(
	        rCntlInfo.getOperatorUin(), 
	        rCntlInfo.getOperatorKey().c_str(),
	        rCntlInfo.getOperatorClientIP());
	
		if(const_cast<CCntlInfo&>(rCntlInfo).isRouteKeySet())	
			CCGI_STUB_CNTL->setUin(const_cast<CCntlInfo&>(rCntlInfo).getRouteKey());	
	    
	    int iRetCode = 0;
		m_sErrMsg.clear();
		if((iRetCode = CCGI_STUB_CNTL->putSvcObj(&oReq, 0)) != 0)
	    {
			m_sErrMsg = "DoRequest failed: ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
	        return iRetCode;
	    }
	    
	    // Send & Recv
		if((iRetCode = SendRecv()) != 0)
		{
			if(99 == iRetCode) // UDP & Need No Response
				return 0;
	
			std::stringstream oss;
			oss << m_lTimeout;
	        m_sErrMsg = "Send & Recv Timeout(";
			m_sErrMsg += oss.str();
			m_sErrMsg += "s) ";
			m_sErrMsg += CCGI_STUB_CNTL->GetLastErrMsg();
			return iRetCode;
	    }
	    
		if(!m_poCmd->isValid(ORGANIZATIONDAO_MODIFYBRANCH_RESP_CMD_ID))
	    {
	        std::stringstream oss;
            oss << "Cmd not match: "
                << "Expected cmd=" << std::hex << ORGANIZATIONDAO_MODIFYBRANCH_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << m_poCmd->getCmdId() << std::dec;
            m_sErrMsg = oss.str();
        
	        return 0xEE0024;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    m_poCmd->getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CModifyBranchResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0028;
	    }
		    
			errmsg  = oResp.errmsg;
			outReserve  = oResp.outReserve;
		    
		return oResp.dwResult;
	}
		
}
}
}

#endif /* ORGANIZATIONDAO_STUB_4_WEB_H */
